<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--标准mui.css-->
    <link rel="stylesheet" href="../static/weixinKp/css/mui.min.css">
    <link rel="stylesheet" href="../static/weixinKp/css/main.css">
    <!--App自定义的css-->
    <!-- <link rel="stylesheet" type="text/css" href="./css/app.css" /> -->
    <title>开票</title>
    <style media="screen">
        .hassalelist {
            color: #2e78ff;
            text-indent: 1em;
        }
        .invoiceAllInfo {
            font-size: 14px;
            color: #fff;
            height: 40px;
            line-height: 40px;
            text-indent: 1em;
            background-color: #f38d61;
            display: none;
        }
        .icon-close {
            margin-top: -2px;
            margin-right: 4px;
            width: 24px;
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div class="wrap" style="margin-bottom: 50px;">
        <div class="invoiceAllInfo">
            <img src="images/icon-close.png" alt="" class="icon-close">点击查看贵司发票版本、联次信息
        </div>
        <div class="top">
            <div><span class="active">普票</span></div>
            <div><span>专票</span></div>
            <div><span>电子</span></div>
            <div><span>通用机打</span></div>
        </div>
        <div class="delegate">
            <div class="deleName">
                <div class="left">委方信息</div>
                <div class="right"><span class="NotChoose" id="notC">未选择</span> <img src="./images/down.png" alt="" class="icon-top"></div>
            </div>
            <div class="deleDetail">
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>名称</div>
                    <div class="right" id="entrust"><span>请输入委方全称</span> <img src="./images/right.png" alt="" class="icon-right"></div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>纳税人识别号</div>
                    <div class="right"><input type="text" value='' class="number" id="taxpayerid"></div>
                </div>
                <div class="deleInfo account">
                    <div class="left"><span class="red">*</span>开户行及帐号</div>
                    <div class="right bankInfo">
                        <div class="bankName" id="bankname"></div>
                        <img src="./images/right.png" alt="" class="icon-more">
                    </div>
                </div>
                <div class="deleInfo account">
                    <div class="left"><span class="red">*</span>公司地址</div>
                    <div class="right">
                        <textarea name="name" class="account_area" id="registeraddress"></textarea>
                    </div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>联系人</div>
                    <div class="right"><input type="text" value='' class="number" id="contacter"></div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>联系电话</div>
                    <div class="right"><input type="text" value='' class="number" id="contactphone" maxlength="11"></div>
                </div>
            </div>
        </div>
        <!-- 购方信息 -->
        <div class="delegate">
            <div class="deleName">
                <div class="left">购方信息</div>
                <div class="right"><span class="NotChoose" id="notG">未选择</span> <img src="./images/down.png" alt="" class="icon-top"></div>
            </div>
            <div class="deleDetail">
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>名称</div>
                    <div class="right" id="purchaser"><span id="buyername">请输入购方全称</span> <img src="./images/right.png" alt="" class="icon-right"></div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>纳税人识别号</div>
                    <div class="right"><input type="text" value='' class="number" readonly="readonly" id="taxpayerids"></div>
                </div>
                <div class="deleInfo account">
                    <div class="left"><span class="red">*</span>开户行及帐号</div>
                    <div class="right">
                        <div class="bankName" id="bankaccount"></div>
                    </div>
                </div>
                <div class="deleInfo account">
                    <div class="left"><span class="red">*</span>公司地址</div>
                    <div class="right">
                        <textarea name="name" class="account_area" readonly="readonly" id="registeraddres_c"></textarea>
                    </div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>联系人</div>
                    <div class="right"><input type="text" value='' class="number" readonly="readonly" id="contacters"></div>
                </div>
                <div class="deleInfo">
                    <div class="left"><span class="red">*</span>联系电话</div>
                    <div class="right"><input type="text" value='' class="number" readonly="readonly" id="contactphones"></div>
                </div>
                <div class="deleInfo eml" style="display:none;">
                    <div class="left"><span class="red">*</span>电子邮箱</div>
                    <div class="right"><input type="text" value='' class="number" readonly="readonly" id="buyerEmail"></div>
                </div>
            </div>
        </div>
        <div class="delegate">
            <div class="deleName">
                <div class="left">商品信息</div>
                <div class="right" id="GoodInfo"><span class="NotChoose" id="notGood">未选择</span> <img src="./images/right.png" alt="" class="icon-right"></div>
            </div>
        </div>

        <div class="delegate" style="margin-top:10px;">
            <div class="deleDetail" style="display:block;">
                <!-- 发票版本 -->
                <div class="deleInfo">
                    <div class="left">发票版本</div>
                    <div class="right InvoiceVersion">
                        <span class="NotChoose" id="InvoiceVersion">未选择</span><img src="./images/right.png" alt="" class="icon-right">
                    </div>
                </div>
                <!-- 发票联次 -->
                <div class="deleInfo">
                    <div class="left">发票联次</div>
                    <div class="right InvoiceSheet">
                        <span class="NotChoose" id="InvoiceSheet">未选择</span><img src="./images/right.png" alt="" class="icon-right">
                    </div>
                </div>
                <!-- 发票备注 -->
                <div class="deleInfo account">
                    <div class="left">发票备注</div>
                    <div class="right">
                        <textarea name="name" class="account_area" id="InvoiceRemark"></textarea>
                    </div>
                </div>
            </div>
        </div>
        <!-- 是否有销货清单 -->
        <div class="delegate">
            <div class="deleNames">
                <div class="left">是否有销货清单</div>
                <div class="right"><img src="./images/express_btn_03_n.png" alt="" class="icon-ors"></div>
            </div>
            <div class="deleInfo hassalelist" style="display:none">
                销货清单请发至邮箱：<span></span>
            </div>
        </div>
        <!-- 邮寄发票 -->
        <div class="delegate">
            <div class="deleNames">
                <div class="left">是否需要邮寄发票</div>
                <div class="right"><img src="./images/express_btn_03_n.png" alt="" class="icon-or"></div>
            </div>
            <div class="deleInfo" style="display:none">
                <div class="left">邮寄地址</div>
                <div class="right mailAddress">
                    <span class="NotChoose" id="mailAddress"></span><img src="./images/right.png" alt="" class="icon-right">
                </div>
            </div>
        </div>
        <!-- 给我留言 -->
        <div class="deleInfo account" style="margin-top:10px;">
            <div class="left">给我留言</div>
            <div class="right">
                <textarea name="name" class="account_area" id="GiveMeWords" placeholder=""></textarea>
            </div>
        </div>
        <footer class="footer">
            提交
        </footer>
    </div>
    <!-- 第一层 -->
    <div class="big">
        <div class="anit_rigth">

        </div>
    </div>
    <!-- 第二层 -->
    <div class="big_agian">
        <div class="anit_rigth_agian">

        </div>
    </div>
    <!-- 选择税率 -->
    <div class="rate">
        <div class="chooserate">

        </div>
    </div>
    <!-- 委方 customerId -->
    <input type="hidden" value="" id="customerId">
    <!-- 委方 银行 -->
    <input type="hidden" value="" id="conBankname">
    <!-- 委方 账户 -->
    <input type="hidden" value="" id="conBankaccount">
    <!-- 购方  userId -->
    <input type="hidden" value="" id="userId">
    <!-- 购方 buyerId -->
    <input type="hidden" value="" id="buyerIds">
    <!-- 购方 银行 -->
    <input type="hidden" value="" id="buyerBankname">
    <!-- 购方 账户 -->
    <input type="hidden" value="" id="buyerBankaccount">
    <!-- 购方 商品总价 -->
    <input type="hidden" value="" id="invoicetotalmoney">
    <!-- 购方 邮箱 -->
    <!-- <input type="hidden" value="" id="buyerEmail"> -->
    <!-- 小规模纳税人 -->
    <input type="hidden" value="" id="reporttaxtype">
    <!-- 是否建议增收 -->
    <input type="hidden" value="" id="issimplecollection">
    <!-- 商品ID -->
    <input type="hidden" value="" id="goodId">
    <!-- 邮寄地址ID -->
    <input type="hidden" value='' id="AdsId">
    <!-- 发票类型 -->
    <input type="hidden" value="1" id="invoiceType">
    <!-- 发票联次 -->
    <input type="hidden" value='' id="invoiceunion">
    <!-- 发票版本 -->
    <input type="hidden" value="1" id="invoiceversion">
    <!-- 发票是否邮寄 -->
    <input type="hidden" value="0" id="isneedpost">
    <!-- 发票付费方式 -->
    <input type="hidden" value="" id="payway">
    <!-- 发票邮寄 邮寄人 -->
    <input type="hidden" value="" id="recepter">
    <!-- 发票邮寄 邮寄号码 -->
    <input type="hidden" value="" id="receptphone">
    <!-- 是否需要销货清单 -->
    <input type="hidden" value="" id="ishassalelist">
</body>
<script src="../static/weixinKp/js/mui.min.js"></script>
<script src="../static/weixinKp/js/jquery-3.2.1.min.js" charset="utf-8"></script>
<script src="../static/weixinKp/js/zepto.js" charset="utf-8"></script>
<script type="text/javascript" src="../static/weixinKp/js/path.js"></script>
<script type="text/javascript">
    var userId = document.cookie.split(";")[1].split("=")[1];
    var datajson;
    var wHeight = window.innerHeight; //获取初始可视窗口高度
    window.addEventListener('resize', function() { //监测窗口大小的变化事件
        var hh = window.innerHeight; //当前可视窗口高度
        var viewTop = $(window).scrollTop(); //可视窗口高度顶部距离网页顶部的距离
        if (wHeight > hh) { //可以作为虚拟键盘弹出事件
            $(".bottoms").hide();
        } else { //可以作为虚拟键盘关闭事件
            //$("content").animate({scrollTop:viewTop-100});
            $(".bottoms").show();
        }
        wHeight = hh;
    });
    var username = document.cookie.split(";")[0].split("=")[1];
    var recordGoodsList = new Array();
    var goodId = new Array();
    // 显示侧边框
    function SildShow() {
        $(".big").show();
        $(".anit_rigth").animate({
            left: '20%'
        });
        $(".anit_rigth").empty();
    }
    //选择委托人
    $(document).on('touchstart', '#entrust', function() {
        $.ajax({
            url: path + '/app/customer/list',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            success: function(data) {
                if (data.success == 1) {
                    SildShow();
                    var html = '';
                    html += '<div class="nameways">公司<span id="back">返回</span></div>';
                    html += '<div class="mui-input-row mui-search">';
                    html += '<input type="search" class="mui-input-clear" placeholder="请输入公司名称，例如：九洲" id="W_sear">';
                    html += '</div>';
                    html += '<div class="company_list">';
                    for (var i = 0; i < data.data.length; i++) {
                        html += '<div class="info_name selectC">';
                        html += '<span>' + data.data[i].customername + '</span>';
                        html += '<input type="hidden" value="' + data.data[i].customerId + '"/>';
                        html += '</div>';
                    }
                    html += '</div>';
                    $('.anit_rigth').append(html);
                } else if (data.success == 0) {
                    mui.alert(data.message, function() {
                        window.location.replace('./login.html');
                    })
                }
            },
            error: function(err) {
                mui.alert(err.message);
            }
        })

    })
    //点击第一层返回
    $(document).on('touchstart', '#back', function() {
        $(".anit_rigth").animate({
            left: '100%'
        }, 'slow', function() {
            $(".big").hide();
        });
    })
    //点击第一层返回
    $(document).on('touchstart', '.W_back', function() {
        var set = document.querySelectorAll('.set_default');
        if (set.length == 0) {
            $('#bankname').text('');
            $("#conBankname").val('');
            $("#conBankaccount").val('');
        }
    })
    //点击公司信息
    $(document).on('touchstart', ".info_name", function() {
        $(".anit_rigth").animate({
            left: '100%'
        }, 'slow', () => {
            $(".big").hide();
            $("#entrust span").text($(this).find('span').text());
            $("#customerId").val($(this).find('input').val())
            $(".anit_rigth").empty();
            $.ajax({
                url: path + '/app/customer/detail',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    "customerId": $("#customerId").val()
                },
                success: (data) => {
                    $("#taxpayerid").val(data.data.taxpayerid);
                    $("#contacter").val(data.data.contacter);
                    $("#contactphone").val(data.data.contactphone);
                    $("#registeraddress").val(data.data.registeraddress)
                    $("#bankname").text(data.data.bankname + data.data.bankaccountnumber);
                    $("#reporttaxtype").val(data.data.reporttaxtype);
                    $("#issimplecollection").val(data.data.issimplecollection);
                    $("#conBankname").val(data.data.bankname);
                    $("#conBankaccount").val(data.data.bankaccountnumber);
                    $("#notC").text('已选择');
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            });
            $.ajax({
                url: path + '/app/customerInv/list',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    customerId: $("#customerId").val()
                },
                success: (data) => {
                    console.log('data====' + data);
                    datajson = data;
                    var html = '';
                    $.each(data.data, function(index, datas) {
                        if (datas.invoiceTypeName == '增值税普通发票') {
                            html += '普票 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
                        } else if (datas.invoiceTypeName == '电子发票') {
                            html += '电子 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
                        } else if (datas.invoiceTypeName == '通用机打发票') {
                            html += '通用机打 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
                        } else if (datas.invoiceTypeName == '增值税专用发票') {
                            html += '专票 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
                        }
                    })
                    mui.alert(html, data.data[0].customername, '知道了');
                    $(".invoiceAllInfo").show();
                },
                error: (err) => {
                    mui.alert(err.message)
                }
            })
        });
    })
    //选择公司确定
    $(document).on('touchstart', '#sure', function() {
        $('.icon').each(() => {
            if ($(this).is(":hidden")) {

            } else {
                var text = $(this).prev().text();
                $(".anit_rigth").animate({
                    left: '100%'
                }, 'slow', function() {
                    $('.seled_compay').text(text);
                    $(".big").hide();
                    $(".anit_rigth").empty();
                });
            }
        })
    })

    // 选择发票类型
    $('.top div span').click(function() {
        $('#invoiceType').val(($(this).parent().index() + 1));
        $(this).addClass('active');
        $(this).parents('div').siblings().find('span').removeClass('active');
        if (($(this).parent().index() + 1) == 3) {
            $('.eml').show();
        } else {
            $('.eml').hide();
        }
    })

    //     选择委方信息
    $('.deleName').click(function() {
        $(this).siblings().slideToggle(500);
        if ($(this).find('.icon-top').attr('src') == './images/down.png') {
            $(this).find('.icon-top').attr('src', './images/top.png')
        } else {
            $(this).find('.icon-top').attr('src', './images/down.png');
        }
    })

    //  选择委方开户行及帐号
    $(".bankInfo").click(function() {
        loadBank();
    })

    function loadBank() {
        var customer = $("#customerId").val();
        if (customer == '') {
            mui.alert('请选取委方信息!');
            return;
        } else {
            $.ajax({
                url: path + '/app/customerBank/list',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    customerId: customer
                },
                success: (data) => {
                    SildShow();
                    var html = '';
                    html += '<div class="nameways">委方开户行及帐号<span id="back" class="W_back">返回</span><span id="complete" class="W_com">完成</span></div>';
                    html += '<div class="acountInfo">';
                    if (data.data.length > 0) {
                        for (var i = 0; i < data.data.length; i++) {
                            html += '<div class="account_list">';
                            html += '<p class="account_detail">' + data.data[i].bankname + '</p>';
                            html += '<p class="account_detail">' + data.data[i].bankaccountnumber + '</p>';
                            html += '</div>';
                            html += '<div class="acount_opert">';
                            html += '<input type="hidden" value="' + data.data[i].id + '"/>';
                            if (data.data[i].isdefault == 1) {
                                html += '<span class="set_default"><img src="./images/express_btn_02_s.png" alt="" class="img_btn02">设为默认</span>';
                            } else {
                                html += '<span class="set_default"><img src="./images/express_btn_02_n.png" alt="" class="img_btn02">设为默认</span>';
                            }
                            html += '<span class="delect_info W_del"><img src="./images/express_delete.png" alt="" class="icon_delect">删除</span>';
                            html += '<span class="edit_info Edit_W"><img src="./images/express_edit.png" alt="" class="icon_edit">编辑</span>';
                            html += '</div>';
                        }
                    } else {
                        html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                        html += '<p class="result_note">暂无开户行和账户信息！</p>';
                    }
                    html += '</div>';
                    html += '<div class="bottom AddW">';
                    html += '新增';
                    html += '</div>';
                    $('.anit_rigth').append(html);
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            })
        }
    }
    // 编辑 委托方账户信息
    $(document).on('touchstart', ".Edit_W", function() {
        let id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/customerBank/detail',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            dataType: 'json',
            success: (data) => {
                $('.anit_rigth_agian').empty();
                var html = '';
                html += '<input type="hidden" value="' + id + '" id="id"/>';
                html += '<div class="nameways">编辑<span id="backs">返回</span></div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>开户行</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.bankname + '" id="banknames">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>帐号</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.bankaccountnumber + '" id="bankaccountnumbers" maxlength="19">';
                html += '</div>';
                html += '</div>';
                html += '<div class="bottoms bankSave">';
                html += '保存';
                html += '</div>';
                $('.anit_rigth_agian').append(html);
                //$('.bottoms').css('top',height-45);
                $('.big_agian').show();
                $('.anit_rigth_agian').show();
                $('.big').hide();
                $('.anit_rigth').hide();
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 点击委托方银行账户的完成
    $(document).on('touchstart', '.W_com', function() {
        var set = document.querySelectorAll('.set_default');
        if (set.length == 0) {
            $('#bankname').text('');
            $("#conBankname").val('');
            $("#conBankaccount").val('');
        } else {
            $('.set_default').each(function() {
                var src = $(this).find('img').attr('src');
                if (src == './images/express_btn_02_s.png') {
                    var bankname = $(this).parent().prev().find('p').eq(0).text();
                    var banknum = $(this).parent().prev().find('p').eq(1).text();
                    $('#bankname').text(bankname + banknum);
                }
            })
        }
    })
    // 点击委托开户账户新增
    $(document).on('touchstart', '.AddW', () => {
        $('.anit_rigth_agian').empty();
        var html = '';
        html += '<input type="hidden" value="" id="id"/>';
        html += '<div class="nameways">新增<span id="backs">返回</span></div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>开户行</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入开户行" id="banknames">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>帐号</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入帐号" id="bankaccountnumbers">';
        html += '</div>';
        html += '</div>';
        html += '<div class="bottoms bankSave">';
        html += '保存';
        html += '</div>';
        $('.anit_rigth_agian').append(html);
        //$('.bottoms').css('top',height-45);
        $('.big_agian').show();
        $('.anit_rigth_agian').show();
        $('.big').hide();
        $('.anit_rigth').hide();

    })
    // 新增或保存 委托方银行账户
    $(document).on('touchstart', '.bankSave', function() {
        var id = $("#id").val();
        var customerId = $("#customerId").val();
        var banknames = $("#banknames").val();
        var bankaccountnumbers = $("#bankaccountnumbers").val();
        if (bankaccountnumbers == '') {
            mui.alert('请输入帐号！');
            return;
        } else if (banknames == '') {
            mui.alert('请输入开户行名称！');
            return;
        }
        $.ajax({
            url: path + '/app/customerBank/save',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            data: {
                id: id,
                bankaccountnumber: bankaccountnumbers,
                bankname: banknames,
                customerId: customerId
            },
            success: (data) => {
                if (data.success == 1) {
                    mui.alert(data.message);
                    loadBank();
                    $('.big_agian').hide();
                    $('.anit_rigth_agian').hide();
                    $('.anit_rigth_agian').empty();
                    $('.big').show();
                    $('.anit_rigth').show();
                } else if (data.success == 0) {
                    mui.alert(data.message);
                }
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 删除委托方银行账户
    $(document).on('touchstart', ".W_del", function() {
        var id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/customerBank/del',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            dataType: 'json',
            success: (data) => {
                mui.alert('删除成功');
                loadBank();
                $('.big_agian').hide();
                $('.anit_rigth_agian').hide();
                $('.anit_rigth_agian').empty();
                $('.big').show();
                $('.anit_rigth').show();
            },
            error: (err) => {

            }
        })
    })
    // 返回
    function hideIn() {
        $(".anit_rigth").animate({
            left: '100%'
        }, 'slow', function() {
            $(".big").hide();
        });
    }
    //点击第二层返回
    $(document).on('touchstart', '#backs', () => {
        $('.anit_rigth_agian').empty();
        $('.big_agian').hide();
        $('.anit_rigth_agian').hide();
        $('.big').show();
        $('.anit_rigth').show();
    })
    //点击第三层返回
    $(document).on('touchstart', '#back_t', () => {
        $('.anit_rigth').empty();
        GoodList();
        $('.big_agian').show();
        $('.anit_rigth_agian').show();
        $('.big').hide();
        $('.anit_rigth').hide();

    })
    //委方开户行帐号  设置默认
    $(document).on('touchstart', '.set_default', function() {
        var that = this;
        var id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/customerBank/detail',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            data: {
                id: id
            },
            success: function(data) {
                if (data.success == 1) {
                    var bankname = $(that).parent().prev().find('p').eq(0).text();
                    var banknum = $(that).parent().prev().find('p').eq(1).text();
                    $('#bankname').text(bankname + banknum);
                    $(that).find('img').attr('src', './images/express_btn_02_s.png');
                    $(that).parents('.acount_opert').siblings('.acount_opert').find('.set_default img').attr('src', './images/express_btn_02_n.png');
                } else if (data.success == 0) {
                    mui.alert(data.message);
                }
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 委托方信息选择 点击完成
    $(document).on('touchstart', '#complete', function() {
        $(".anit_rigth").animate({
            left: '100%'
        }, 'slow', function() {
            $(".big").hide();
        });
    })
    /**
     * 购方信息
     */
    // 购方信息  公司列表
    function BuyCompany() {
        $.ajax({
            url: path + '/app/buyer/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            success: (data) => {
                SildShow();
                var html = '';
                html += '<div class="nameways">购方<span id="back" class="B_buy">返回</span><span id="complete" class="complete">完成</span></div>';
                html += '<div class="acountInfo">';
                if (data.data.length > 0) {
                    for (var i = 0; i < data.data.length; i++) {
                        html += '<div class="account_list">';
                        html += '<p class="account_detail">' + data.data[i].buyername + '</p>';
                        html += '</div>';
                        html += '<div class="acount_opert">';
                        html += '<input type="hidden" value="' + data.data[i].buyerId + '" />';
                        if (data.data[i].isdefault == 1) {
                            html += '<span class="set_default_buy"><img src="./images/express_btn_02_s.png" alt="" class="img_btn02">设为默认</span>';
                            $("#buyerIds").val(data.data[i].buyerId);
                        } else {
                            html += '<span class="set_default_buy"><img src="./images/express_btn_02_n.png" alt="" class="img_btn02">设为默认</span>';
                        }
                        html += '<span class="delect_info B_del"><img src="./images/express_delete.png" alt="" class="icon_delect">删除</span>';
                        html += '<span class="edit_info_buy"><img src="./images/express_edit.png" alt="" class="icon_edit">编辑</span>';
                        html += '</div>';
                    }
                } else {
                    html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                    html += '<p class="result_note">暂无购方信息！</p>';
                }
                html += '</div>';
                html += '<div class="Buy_bottom">';
                html += '新增';
                html += '</div>';
                $('.anit_rigth').append(html);
            },
            error: (error) => {
                mui.alert(error.message);
            }
        })
    }
    //购方信息 选择
    $('#purchaser').click(() => {
        BuyCompany();
    })
    // 购方信息  设置默认的信息
    $(document).on('touchstart', '.set_default_buy', function() {
        var that = this;
        var buyerId = $(this).parent().find('input').val();
        $("#buyerIds").val(buyerId);
        $.ajax({
            url: path + '/app/buyer/detail',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                buyerId: buyerId
            },
            success: (data) => {
                $(that).find('img').attr('src', './images/express_btn_02_s.png');
                $(that).parents('.acount_opert').siblings('.acount_opert').find('.set_default_buy img').attr('src', './images/express_btn_02_n.png');
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 购方信息  点击完成
    $(document).on('touchstart', '.complete', () => {
        var set_default_buy = document.querySelectorAll('.set_default_buy');
        if (set_default_buy.length > 0) {
            var buyerId = $("#buyerIds").val();
            if (buyerId == '') {
                mui.alert('请选择购方信息!');
                return;
            }
            $.ajax({
                url: path + '/app/buyer/detail',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    buyerId: buyerId
                },
                success: (data) => {
                    $("#notG").text('已选择');
                    $("#bankaccount").text(data.data.bankname + data.data.bankaccount);
                    $("#buyername").text(data.data.buyername);
                    $("#taxpayerids").val(data.data.taxpayerid);
                    $("#registeraddres_c").val(data.data.registeraddress);
                    $("#contacters").val(data.data.contacter);
                    $("#contactphones").val(data.data.contactphone);
                    $("#buyerBankname").val(data.data.bankname);
                    $("#buyerBankaccount").val(data.data.bankaccount);
                    $("#buyerEmail").val(data.data.email);
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            })
        } else {
            $("#buyerIds").val('');
            $("#notG").text('未选择');
            $("#bankaccount").text('');
            $("#buyername").text('');
            $("#taxpayerids").val('');
            $("#registeraddres_c").val('');
            $("#contacters").val('');
            $("#contactphones").val('');
            $("#buyerBankname").val('');
            $("#buyerBankaccount").val('');
            $("#buyerEmail").val('');
        }

    })
    // 购方信息   点击返回
    $(document).on('touchstart', '.B_buy', function() {
        var set_default_buy = document.querySelectorAll('.set_default_buy');
        if (set_default_buy.length == 0) {
            $("#buyerIds").val('');
            $("#notG").text('未选择');
            $("#bankaccount").text('');
            $("#buyername").text('');
            $("#taxpayerids").val('');
            $("#registeraddres_c").val('');
            $("#contacters").val('');
            $("#contactphones").val('');
            $("#buyerBankname").val('');
            $("#buyerBankaccount").val('');
            $("#buyerEmail").val('');
        }
    })
    // 购方信息  编辑信息
    $(document).on('touchstart', '.edit_info_buy', function() {
        var that = this;
        var buyerId = $(this).parent().find('input').val();
        $("#buyerIds").val(buyerId);
        $.ajax({
            url: path + '/app/buyer/detail',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                buyerId: buyerId
            },
            success: (data) => {
                var html = '<div class="nameways">编辑<span id="backs">返回</span></div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>名称</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入购方全称" value="' + data.data.buyername + '" id="Edit_buyername">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>纳税人识别号</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入购方纳税人识别号" value="' + data.data.taxpayerid + '" id="Edit_taxpayeride">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>开户行</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入购方开户行" value="' + data.data.bankname + '" id="Edit_bankname">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>开户账号</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入购方开户账号" value="' + data.data.bankaccount + '" id="Edit_bankaccount" maxlength="19">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>地址</div>';
                html += '<div class="input_right">';
                html += '<textarea name="name" class="buy_area" placeholder="请输入地址" id="Edit_registeraddress">' + data.data.registeraddress + '</textarea>';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>联系人</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入联系人" value="' + data.data.contacter + '" id="Edit_contacter"/>';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>联系电话</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入联系电话" value="' + data.data.contactphone + '" id="Edit_contactphone" maxlength="11"/>';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left">电子邮箱</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入电子邮箱" value="' + data.data.email + '" id="Edit_email"/>';
                html += '</div>';
                html += '</div>';
                html += '<div class="buy_note">维护邮箱可用于接受电子发票</div>';
                html += '<img src="./images/warn.png" alt="" class="warn">';
                html += '<div class="bottoms buySave">保存</div>';

                $(".anit_rigth_agian").append(html);
                //$('.bottoms').css('top',height-45);
                $('.big_agian').show();
                $('.anit_rigth_agian').show();
                $('.big').hide();
                $('.anit_rigth').hide();
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    //购方信息  新增
    $(document).on('touchstart', '.Buy_bottom', () => {
        $("#buyerIds").val('');
        var html = '<div class="nameways">新增<span id="backs">返回</span></div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>名称</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方全称" value="" id="Edit_buyername">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>纳税人识别号</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方纳税人识别号" value="" id="Edit_taxpayeride" maxlength="20">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>开户行</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方开户行" value="" id="Edit_bankname">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>开户账号</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方开户账号" value="" id="Edit_bankaccount" maxlength="19">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>地址</div>';
        html += '<div class="input_right">';
        html += '<textarea name="name" class="buy_area" placeholder="请输入购方地址" id="Edit_registeraddress"></textarea>';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>联系人</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方联系人" value="" id="Edit_contacter"/>';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>联系电话</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方联系电话" value="" id="Edit_contactphone" maxlength="11"/>';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left">电子邮箱</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入购方电子邮箱" value="" id="Edit_email"/>';
        html += '</div>';
        html += '</div>';
        html += '<div class="buy_note">维护邮箱可用于接受电子发票</div>';
        html += '<img src="./images/warn.png" alt="" class="warn">';
        html += '<div class="bottoms buySave">保存</div>';
        $('.anit_rigth_agian').append(html);
        //$('.bottoms').css('top',height-45);
        $('.big_agian').show();
        $('.anit_rigth_agian').show();
        $('.big').hide();
        $('.anit_rigth').hide();
    })
    // 购方信息  保存
    $(document).on('touchstart', '.buySave', () => {
        var buyerId = $("#buyerIds").val();
        var Edit_buyername = $("#Edit_buyername").val();
        var Edit_taxpayeride = $("#Edit_taxpayeride").val();
        var Edit_bankname = $("#Edit_bankname").val();
        var Edit_bankaccount = $("#Edit_bankaccount").val();
        var Edit_registeraddress = $("#Edit_registeraddress").val();
        var Edit_contacter = $("#Edit_contacter").val();
        var Edit_contactphone = $("#Edit_contactphone").val();
        var Edit_email = $("#Edit_email").val();
        var invoiceType = $("#invoiceType").val();
        if (invoiceType == 3) {
            if (Edit_email == '') {
                mui.alert('请输入电子邮箱！');
                return;
            }
        }
        if (Edit_buyername == '' || Edit_taxpayeride == '' || Edit_bankname == '' || Edit_bankaccount == '' || Edit_registeraddress == '' || Edit_contacter == '' || Edit_contactphone == '') {
            mui.alert('请输入完整信息！');
            return;
        }
        $.ajax({
            url: path + '/app/buyer/save',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            data: {
                buyerId: buyerId,
                buyername: Edit_buyername,
                taxpayerid: Edit_taxpayeride,
                bankname: Edit_bankname,
                bankaccount: Edit_bankaccount,
                registeraddress: Edit_registeraddress,
                contacter: Edit_contacter,
                contactphone: Edit_contactphone,
                email: Edit_email
            },
            success: (data) => {
                console.log(data);
                if (data.success == 1) {
                    mui.alert('保存成功！');
                    BuyCompany();
                    $('.big_agian').hide();
                    $('.anit_rigth_agian').hide();
                    $('.anit_rigth_agian').empty();
                    $('.big').show();
                    $('.anit_rigth').show();
                } else if (data.success == '0') {
                    mui.alert('保存失败！');
                }
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 购方信息   删除
    $(document).on('touchstart', ".B_del", function() {
        var id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/buyer/del',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                buyerId: id
            },
            dataType: 'json',
            success: (data) => {
                if (data.success == 1) {
                    mui.alert('删除成功');
                    BuyCompany();
                    $('.big_agian').hide();
                    $('.anit_rigth_agian').hide();
                    $('.anit_rigth_agian').empty();
                    $('.big').show();
                    $('.anit_rigth').show();
                } else if (data.success == '0') {
                    mui.alert('删除失败！');
                }
            },
            error: (err) => {

            }
        })
    })
    // 商品信息列表
    function GoodList() {
        var customerId = $("#customerId").val();
        var buyerId = $("#buyerIds").val();
        $.ajax({
            url: path + '/app/goods/list',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            data: {
                customerId: customerId,
                buyerId: buyerId
            },
            success: (data) => {
                console.log(data);
                var html = '';
                html += '';
                html += '<div class="nameways">商品<span id="back">返回</span><span class="G_com">完成</span></div>';
                html += '<div class="GoodList">';
                if (data.data.length > 0) {
                    for (var i = 0; i < data.data.length; i++) {
                        html += '<div class="GoodName">';
                        html += '<input type="hidden" value="' + data.data[i].id + '"/>';
                        html += '<span class="set_default_G"><img src="./images/express_btn_02_n.png" alt="" class="img_btn02">' + data.data[i].goodsname + '</span>';
                        html += '<span class="delect_info DeleGoods"><img src="./images/express_delete.png" alt="" class="icon_delect">删除</span>';
                        html += '<span class="edit_info EditGoods"><img src="./images/express_edit.png" alt="" class="icon_edit">编辑</span>';
                        html += '</div>';
                        html += '<div class="GoodInfoName">';
                        html += ' <span>行业</span>';
                        html += '<span>税率</span>';
                        html += '<span>含税总价</span>';
                        html += '</div>';
                        html += '<div class="GoodInfoNum">';
                        html += '<span class="GoodIndustry">' + data.data[i].industryname + '</span>';
                        html += '<span class="GoodRate">' + data.data[i].taxrate + '</span>';
                        html += '<span class="GoodTotal">' + data.data[i].totalprice + '</span>';
                        html += '</div>';
                    }
                } else {
                    html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                    html += '<p class="result_note">暂无商品信息！</p>';
                }
                html += '</div>';
                html += '<div class="bottom GoodNews">新增</div>';
                // 获取屏幕的高度
                $('.anit_rigth').append(html);
                var height = window.screen.availHeight;
                $(".GoodList").css('height', height-120);
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    }
    /**
     * 商品信息
     */
    $('#GoodInfo').click(() => {
        var customerId = $("#customerId").val();
        var buyerId = $("#buyerIds").val();
        if (customerId == '') {
            mui.alert('请选择委方信息!');
            return;
        }
        if (buyerId == '') {
            mui.alert('请选择购方信息!');
            return;
        }
        SildShow();
        GoodList();
    })
    // 添加商品
    $(document).on('touchstart', '.GoodNews', function() {
        $("#goodId").val('');
        var html = '';
        html += '<div class="nameways">新增<span id="backs">返回</span></div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>名称</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入商品全称" id="goodsname">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>所属行业</div>';
        html += '<div class="input_right" id="industry">';
        html += '<input type="hidden" value="" id="industryId">';
        html += '<input type="text" value="" placeholder="请输入商品所属行业" readonly id="industryname"><img src="./images/right.png" alt="" class="iconr"/>';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>税率设置</div>';
        html += ' <div class="input_right" id="SelectRate">';
        html += '<input type="text" value="" placeholder="请输入税率" readonly id="taxrate"><img src="./images/right.png" alt="" class="iconr"/>';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left">商品型号</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入商品型号" id="goodsmodel">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left">单位</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入商品单位" id="goodsunit">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left">数量</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入商品数量" id="goodsamount">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left">含税单价(￥)</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入含税单价" id="unitprice">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>含税总价(￥)</div>';
        html += '<div class="input_right">';
        html += '<input type="text" value="" placeholder="请输入含税总价" id="totalprice">';
        html += '</div>';
        html += '</div>';
        html += '<div class="bottoms GoodSave">保存</div>';
        $('.anit_rigth_agian').empty();
        $('.anit_rigth_agian').append(html);
        //$('.bottoms').css('top',height-45);
        $('.big_agian').show();
        $('.anit_rigth_agian').show();
        $('.big').hide();
        $('.anit_rigth').hide();
    })

    // 点击选择行业
    $(document).on('touchstart', '#industry', () => {
        $.ajax({
            url: path + '/comm/industry/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                pid: 0
            },
            success: (data) => {
                console.log(data);
                var html = '';
                html += '<div class="nameways">公司<span id="back_t">返回</span></div>';
                html += '<div class="mui-input-row mui-search">';
                html += '<input type="search" class="mui-input-clear industy" placeholder="请输入关键字，例如：销售">';
                html += '</div>';
                html += '<div class="industryList">';
                html += '<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                if (data.data.length > 0) {
                    for (var i = 0; i < data.data.length; i++) {
                        if (data.data[i].childCount > 0) {
                            html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                            html += '<p class="industrylist_name">' + data.data[i].spmc + '<img src="./images/right.png" alt="" class="icon-right"/></p>';
                        } else {
                            html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                            html += '<p class="industrylist_name">' + data.data[i].spmc + '</p>';
                        }
                    }
                } else {
                    html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                    html += '<p class="result_note">暂无信息！</p>';
                }
                html += '</div>';
                $('.anit_rigth').empty();
                $('.anit_rigth').append(html);
                $('.big_agian').hide();
                $('.anit_rigth_agian').hide();
                $('.big').show();
                $('.anit_rigth').show();
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 点击选择行业的下级
    $(document).on('touchstart', '.industrylist_name', function() {
        var spbm = $(this).prev().val();
        var spmc = $(this).text();
        $.ajax({
            url: path + '/comm/industry/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                pid: spbm
            },
            success: (data) => {
                console.log(data);
                if (data.data.length == 0) {
                    $("#industryname").val(spmc);
                    $("#industryId").val(spbm);
                    $('#taxrate').val('');
                    GoodList();
                    $('.big_agian').show();
                    $('.anit_rigth_agian').show();
                    $('.big').hide();
                    $('.anit_rigth').hide();
                    $('.anit_rigth').empty();

                } else {
                    var html = '';
                    html += '<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                    for (var i = 0; i < data.data.length; i++) {
                        if (data.data[i].childCount > 0) {
                            html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                            html += '<p class="industrylist_name">' + data.data[i].spmc + '<img src="./images/right.png" alt="" class="icon-right"/></p>';
                        } else {
                            html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                            html += '<p class="industrylist_name">' + data.data[i].spmc + '</p>';
                        }
                    }
                    $(".industryList").empty();
                    $(".industryList").append(html);
                }
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 行业列表点击返回按钮返回第一级
    $(document).on('touchstart', '.industrylist_back', function() {
        $.ajax({
            url: path + '/comm/industry/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                pid: 0
            },
            success: (data) => {
                $('.anit_rigth').empty();
                var html = '';
                html += '<div class="nameways">公司<span id="back_t">返回</span></div>';
                html += '<div class="mui-input-row mui-search">';
                html += '<input type="search" class="mui-input-clear industy" placeholder="请输入关键字，例如：销售">';
                html += '</div>';
                html += '<div class="industryList">';
                html += '<p class="industrylist_back"><img src="./images/icon-back.png" alt="" class="icon-back"/></p>';
                for (var i = 0; i < data.data.length; i++) {
                    if (data.data[i].childCount > 0) {
                        html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                        html += '<p class="industrylist_name">' + data.data[i].spmc + '<img src="./images/right.png" alt="" class="icon-right"/></p>';
                    } else {
                        html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                        html += '<p class="industrylist_name">' + data.data[i].spmc + '</p>';
                    }
                }
                html += '</div>';
                $('.anit_rigth').append(html);
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 选择税率
    $(document).on('touchstart', '#SelectRate', function() {
        var industryId = $("#industryId").val();
        var nalid = $("#reporttaxtype").val();
        var issimplecollection = $("#issimplecollection").val();
        if (industryId) {
            $.ajax({
                url: path + '/comm/tax/list',
                dataType: 'json',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                data: {
                    industryId: industryId,
                    nalid: nalid,
                    issimplecollection: issimplecollection
                },
                success: (data) => {
                    console.log(data);
                    $('.chooserate').empty();
                    var html = '';
                    html += '<p class="rate_title">请选择税率</p>';
                    for (var i = 0; i < data.data.length; i++) {
                        html += '<p class="rate_num">' + data.data[i].taxnum + '</p>';
                    }
                    html += '<p class="rate-cancel">取消</p>';
                    $('.chooserate').append(html);
                    $(".rate").show();
                    $('.chooserate').show();
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            })
        } else {
            mui.alert('请选择行业！');
        }
    })
    // 点击税率取消
    $(document).on('touchstart', '.rate-cancel', function() {
        $(".rate").hide();
        $('.chooserate').hide();
    })
    // 点击选择税率
    $(document).on('touchstart', '.rate_num', function() {
        $("#taxrate").val($(this).text());
        $(".rate").hide();
        $('.chooserate').hide();
    })
    // 点击保存商品信息
    $(document).on('touchstart', '.GoodSave', function() {
        var goodsId = $("#goodId").val();
        var goodsname = $("#goodsname").val();
        var industryname = $("#industryname").val();
        var taxrate = $("#taxrate").val();
        var goodsmodel = $("#goodsmodel").val();
        var goodsunit = $("#goodsunit").val();
        var goodsamount = $("#goodsamount").val();
        var unitprice = $("#unitprice").val();
        var totalprice = $("#totalprice").val();
        var industryId = $("#industryId").val();
        var customerId = $("#customerId").val();
        var buyerId = $("#buyerIds").val();
        if (goodsname == '' || industryname == '' || taxrate == '' || totalprice == '') {
            mui.alert('请输入完整信息！');
            return;
        }
        $.ajax({
            url: path + '/app/goods/save',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: goodsId,
                goodsname: goodsname,
                industryId: industryId,
                industryname: industryname,
                taxrate: taxrate,
                goodsmodel: goodsmodel,
                goodsunit: goodsunit,
                goodsamount: goodsamount,
                unitprice: unitprice,
                totalprice: totalprice,
                customerId: customerId,
                buyerId: buyerId
            },
            success: (data) => {
                console.log(data);
                $('.anit_rigth').empty();
                GoodList();
                $('.big_agian').hide();
                $('.anit_rigth_agian').hide();
                $('.big').show();
                $('.anit_rigth').show();
            },
            error: (err) => {
                mui.alert(err);
            }
        })
    })
    // 编辑商品
    $(document).on('touchstart', '.EditGoods', function() {
        var goodids = $(this).parent().find('input').val();
        $("#goodId").val(goodids);
        $.ajax({
            url: path + '/app/goods/detail',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: goodids
            },
            success: (data) => {
                console.log(data);
                var html = '';
                html += '<div class="nameways">编辑<span id="backs">返回</span></div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>名称</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.goodsname + '" placeholder="请输入商品全称" id="goodsname">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>所属行业</div>';
                html += '<div class="input_right" id="industry">';
                html += '<input type="hidden" value="' + data.data.industryId + '" id="industryId">';
                html += '<input type="text" value="' + data.data.industryname + '" placeholder="请输入商品所属行业" readonly id="industryname"><img src="./images/right.png" alt="" class="iconr"/>';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>税率设置</div>';
                html += ' <div class="input_right" id="SelectRate">';
                html += '<input type="text" value="' + data.data.taxrate + '" placeholder="请输入税率" readonly id="taxrate"><img src="./images/right.png" alt="" class="iconr"/>';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left">商品型号</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.goodsmodel + '" placeholder="请输入商品型号" id="goodsmodel">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left">单位</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.goodsunit + '" placeholder="请输入商品单位" id="goodsunit">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left">数量</div>';
                html += '<div class="input_right">';
                if(data.data.goodsamount==null){
                    html += '<input type="text"  placeholder="请输入商品数量" id="goodsamount">';
                }else{
                    html += '<input type="text" value="' + data.data.goodsamount + '" placeholder="请输入商品数量" id="goodsamount">';
                }
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left">含税单价(￥)</div>';
                html += '<div class="input_right">';
                if(data.data.unitprice==null){
                    html += '<input type="text"  placeholder="请输入商品数量" id="unitprice">';
                }else{
                    html += '<input type="text" value="' + data.data.unitprice + '" placeholder="请输入商品数量" id="unitprice">';
                }
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>含税总价(￥)</div>';
                html += '<div class="input_right">';
                html += '<input type="text" value="' + data.data.totalprice + '" placeholder="请输入含税总价" id="totalprice">';
                html += '</div>';
                html += '</div>';
                html += '<div class="bottoms GoodSave">保存</div>';
                $('.anit_rigth_agian').empty();
                $('.anit_rigth_agian').append(html);
                //$('.bottoms').css('top',height-45);
                $('.big_agian').show();
                $('.anit_rigth_agian').show();
                $('.big').hide();
                $('.anit_rigth').hide();
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 删除商品信息
    $(document).on('touchstart', '.DeleGoods', function() {
        var id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/goods/del',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            success: (data) => {
                if (data.success == 1) {
                    mui.alert("删除成功！");
                    $('.anit_rigth').empty();
                    GoodList();
                } else if (data.success == 0) {
                    mui.alert("删除失败！");
                }
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 选中商品
    $(document).on('touchstart', '.set_default_G', function() {
        var imgsrc = $(this).find('img').attr('src');
        if (imgsrc == './images/express_btn_02_s.png') {
            $(this).find('img').attr('src', './images/express_btn_02_n.png');
            $(this).removeClass('sed');
        } else {
            $(this).find('img').attr('src', './images/express_btn_02_s.png');
            $(this).addClass('sed');
        }
    })
    // //点击商品的完成
    $(document).on('touchstart', '.G_com', () => {
        var j = 0;
        recordGoodsList = [];
        let sed = document.querySelectorAll('.sed');
        if (sed.length > 5) {
            mui.alert('最多只能选择五件商品！');
            return;
        };
        if (sed.length == 0) {
            mui.alert('请至少选择一件商品！');
            return;
        };
        $(".set_default_G").each(function() {
            var src = $(this).find('img').attr('src');
            var id = $(this).parent().find('input').val();
            if (src == './images/express_btn_02_s.png') {
                j++;
                goodId.push(id);
                var goodsamount;
                var goodsmodel;
                var goodsname;
                var goodsunit;
                var industryId;
                var industryname;
                var taxrate;
                var totalprice;
                var unitprice;
                $.ajax({
                    url: path + '/app/goods/detail',
                    dataType: 'json',
                    type: 'post',
                    headers: {
                        userId: userId
                    },
                    xhrFields: {
                        withCredentials: true
                    },
                    async: false,
                    data: {
                        id: id
                    },
                    success: (data) => {
                        console.log(data);
                        goodsamount = data.data.goodsamount;
                        goodsmodel = data.data.goodsmodel;
                        goodsname = data.data.goodsname;
                        goodsunit = data.data.goodsunit;
                        industryId = data.data.industryId;
                        industryname = data.data.industryname;
                        taxrate = data.data.taxrate;
                        totalprice = data.data.totalprice;
                        unitprice = data.data.unitprice;
                    },
                    error: (err) => {}
                })
                recordGoodsList.push({
                    goodsamount,
                    goodsmodel,
                    goodsname,
                    goodsunit,
                    industryId,
                    industryname,
                    taxrate,
                    totalprice,
                    unitprice
                });
            }
        })
        if (j == 0) {
            $("#notGood").text('未选择');
        } else {
            $("#notGood").text('已选择' + j + '件商品');
        }
        hideIn();
    })
    // 打开发票版本 列表
    $(".InvoiceVersion").click(() => {
        $.ajax({
            url: path + '/comm/dic/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                desc: 'invoiceVersion'
            },
            success: (data) => {
                console.log(data);
                $('.chooserate').empty();
                var html = '';
                html += '<p class="rate_title">请选择发票版本</p>';
                for (var i = 0; i < data.data.length; i++) {
                    html += '<p class="thr invoiceV">' + data.data[i].value + '</p>';
                    html += '<input type="hidden" value="' + data.data[i].key + '"/>';
                }
                html += '<p class="rate-cancel">取消</p>';
                $('.chooserate').append(html);
                $(".rate").show();
                $('.chooserate').show();
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    //选中发票版本
    $(document).on('click touchstart', '.invoiceV', function() {
        $('.wrap').css('pointer-events', 'none');
        event.preventDefault();
        var text = $(this).text();
        $("#InvoiceVersion").text(text);
        $('#invoiceversion').val($(this).next().val());
        $(".rate").hide();
        $('.chooserate').hide();
        setTimeout(function() {
            $('.wrap').css('pointer-events', 'auto');
        }, 600);
    })
    // 打开发票联次 列表
    $(".InvoiceSheet").click(function() {
        $.ajax({
            url: path + '/comm/dic/list',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                desc: 'invoiceUnion'
            },
            success: (data) => {
                console.log(data);
                $('.chooserate').empty();
                var html = '';
                html += '<p class="rate_title">请选择发票联次</p>';
                for (var i = 0; i < data.data.length; i++) {
                    html += '<p class="thr invoiceS">' + data.data[i].value + '</p>';
                    html += '<input type="hidden" value="' + data.data[i].key + '"/>';
                }
                html += '<p class="rate-cancel">取消</p>';
                $('.chooserate').append(html);
                $(".rate").show();
                $('.chooserate').show();
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 选中发票联次
    $(document).on('click touchstart', '.invoiceS', function() {
        $('.wrap').css('pointer-events', 'none');
        var text = $(this).text();
        $("#InvoiceSheet").text(text);
        $('#invoiceunion').val($(this).next().val());
        $(".rate").hide();
        $('.chooserate').hide();
        setTimeout(function() {
            $('.wrap').css('pointer-events', 'auto');
        }, 600);
    })
    // 是否需要邮寄发票
    $(".icon-or").click(function() {
        $(this).parents('.deleNames').siblings().slideToggle();
        var src = $(this).attr('src');
        if (src == './images/express_btn_03_n.png') {
            $(this).attr('src', './images/express_btn_03_s.png');
            $(this).parent().next().show();
            $("#isneedpost").val('1');
        } else {
            $(this).attr('src', './images/express_btn_03_n.png');
            $(this).parent().next().hide();
            $("#isneedpost").val('0');
            $("#mailAddress").text('');
            $("#recepter").val('');
            $("#receptphone").val('');
        }
    })
    // 是否需要销货清单
    $(".icon-ors").click(function() {
        $(this).parents('.deleNames').siblings().slideToggle();
        var src = $(this).attr('src');
        if (src == './images/express_btn_03_n.png') {
            $(this).attr('src', './images/express_btn_03_s.png');
            $(this).parent().next().show();
            $("#ishassalelist").val('1');
            $.ajax({
                url: path + '/comm/dic/list',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json',
                data: {
                    desc: 'emailAddr',
                    key: 0
                },
                success: (data) => {
                    if (data.success == 1) {
                        $('.hassalelist span').html(data.data[0].value);
                    } else {
                        mui.alert(data.message)
                    }
                },
                error: (err) => {
                    mui.alert(err.message)
                }
            })
        } else {
            $(this).attr('src', './images/express_btn_03_n.png');
            $(this).parent().next().hide();
            $('.hassalelist span').html('');
            $("#ishassalelist").val('0');
        }
    })
    // 邮寄地址列表
    function AdsList() {
        $('.anit_rigth').empty();
        $.ajax({
            url: path + '/app/postAddress/list',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            dataType: 'json',
            success: (data) => {
                console.log(data);
                var html = '';
                html += '<div class="nameways">邮寄<span id="back">返回</span><span class="AdsCom">完成</span></div>';
                html +=
                    '<div class="mail_way">邮寄方式<span class="mailwany"><img src="./images/express_btn_01_n.png" alt="" /><span>寄付</span></span><span class="mailwany"><img src="./images/express_btn_01_n.png" alt="" /><span>到付</span></span></div>'
                html += '<div class="acountInfo">';
                if (data.data.length > 0) {
                    for (var i = 0; i < data.data.length; i++) {
                        html += '<div class="account_list">';
                        html += '<p class="account_detail"><span>' + data.data[i].recepter + '</span><span class="mailads">' + data.data[i].receptphone + '</span></p>';
                        html += '<p class="account_detail">' + data.data[i].address + '</p>';
                        html += '</div>';
                        html += '<div class="acount_opert">';
                        html += '<input type="hidden" value="' + data.data[i].id + '" />';
                        if (data.data[i].isdefault == 1) {
                            html += '<span class="set_default_Ads"><img src="./images/express_btn_02_s.png" alt="" class="img_btn02">设为默认</span>';
                            $("#AdsId").val(data.data[i].id);
                        } else {
                            html += '<span class="set_default_Ads"><img src="./images/express_btn_02_n.png" alt="" class="img_btn02">设为默认</span>';
                        }
                        html += '<span class="delect_info A_del"><img src="./images/express_delete.png" alt="" class="icon_delect">删除</span>';
                        html += '<span class="edit_info_Ads"><img src="./images/express_edit.png" alt="" class="icon_edit">编辑</span>';
                        html += '</div>';
                    }
                } else {
                    html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                    html += '<p class="result_note">暂无邮寄地址信息！</p>';
                }
                html += '<div class="bottom AddAddress">';
                html += '新增';
                html += '</div>';
                $('.anit_rigth').append(html);
            },
            error: (err) => {
                mui.alert(errr.message);
            }
        })
    }
    // 邮寄地址
    $(".mailAddress").click(() => {
        $('.anit_rigth').empty();
        SildShow();
        AdsList();
    })
    // 邮寄地址选中收件地址
    $(document).on('touchstart', '.set_default_Ads', function() {
        var that = this;
        var id = $(this).parent().find('input').val();
        $("#AdsId").val(id);
        $.ajax({
            url: path + '/app/postAddress/detail',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            success: (data) => {
                $(that).find('img').attr('src', './images/express_btn_02_s.png');
                $(that).parents('.acount_opert').siblings('.acount_opert').find('.set_default_Ads img').attr('src', './images/express_btn_02_n.png');
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    //选中邮寄方式
    $(document).on('touchstart', '.mailwany', function() {
        $(this).find('img').attr('src', './images/express_btn_01_s.png');
        $(this).siblings().find('img').attr('src', './images/express_btn_01_n.png');
        var text = $(this).find('span').text();
        if (text == '寄付') {
            $("#payway").val('1');
        } else if (text == '到付') {
            $("#payway").val('0');
        }
    })
    // 编辑邮寄地址
    $(document).on('touchstart', '.edit_info_Ads', function() {
        var that = this;
        var id = $(this).parent().find('input').val();
        $("#AdsId").val(id);
        $.ajax({
            url: path + '/app/postAddress/detail',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            success: (data) => {
                var html = '<div class="nameways">编辑<span id="backs">返回</span></div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>收件人</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入收件人姓名" value="' + data.data.recepter + '" id="Edit_recepter">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>联系方式</div>';
                html += '<div class="input_right">';
                html += '<input type="text" placeholder="请输入联系方式" value="' + data.data.receptphone + '" id="Edit_receptphone">';
                html += '</div>';
                html += '</div>';
                html += '<div class="input_info">';
                html += '<div class="input_left"><span class="red">*</span>邮寄地址</div>';
                html += '<div class="input_right">';
                html += '<textarea name="name" class="buy_area" placeholder="请输入地址" id="Edit_address">' + data.data.address + '</textarea>';
                html += '</div>';
                html += '</div>';
                html += '<div class="bottoms MailSave">保存</div>';
                $(".anit_rigth_agian").append(html);
                //$('.bottoms').css('top',height-45);
                $('.big_agian').show();
                $('.anit_rigth_agian').show();
                $('.big').hide();
                $('.anit_rigth').hide();
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 保存编辑邮寄地址
    $(document).on('touchstart', '.MailSave', () => {
        var id = $("#AdsId").val();
        var Edit_recepter = $("#Edit_recepter").val();
        var Edit_receptphone = $("#Edit_receptphone").val();
        var Edit_address = $("#Edit_address").val();
        $.ajax({
            url: path + '/app/postAddress/save',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id,
                recepter: Edit_recepter,
                receptphone: Edit_receptphone,
                address: Edit_address
            },
            success: (data) => {
                console.log(data);
                mui.alert('保存成功！');
                AdsList();
                $('.big_agian').hide();
                $('.anit_rigth_agian').hide();
                $('.anit_rigth_agian').empty();
                $('.big').show();
                $('.anit_rigth').show();
            },
            error: (err) => {
                mui.alert(err.message)
            }
        })
    })
    // 新增邮寄地址
    $(document).on('touchstart', '.AddAddress', function() {
        $("#AdsId").val('');
        var html = '<div class="nameways">新增<span id="backs">返回</span></div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>收件人</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入收件人姓名" value="" id="Edit_recepter">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>联系方式</div>';
        html += '<div class="input_right">';
        html += '<input type="text" placeholder="请输入联系方式" value="" id="Edit_receptphone">';
        html += '</div>';
        html += '</div>';
        html += '<div class="input_info">';
        html += '<div class="input_left"><span class="red">*</span>邮寄地址</div>';
        html += '<div class="input_right">';
        html += '<textarea name="name" class="buy_area" placeholder="请输入地址" id="Edit_address"></textarea>';
        html += '</div>';
        html += '</div>';
        html += '<div class="bottoms MailSave">保存</div>';
        $(".anit_rigth_agian").append(html);
        //$('.bottoms').css('top',height-45);
        $('.big_agian').show();
        $('.anit_rigth_agian').show();
        $('.big').hide();
        $('.anit_rigth').hide();
    })
    // 删除邮寄地址
    $(document).on('touchstart', '.A_del', function() {
        var id = $(this).parent().find('input').val();
        $.ajax({
            url: path + '/app/postAddress/del',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            data: {
                id: id
            },
            success: (data) => {
                if (data.success == 1) {
                    mui.alert('删除成功！');
                    AdsList();
                } else if (data.success == 0)(
                    mui.alert('删除失败！')
                )
            },
            error: (err) => {
                mui.alert(err.message);
            }
        })
    })
    // 点击邮寄地址的完成
    $(document).on('touchstart', '.AdsCom', function() {
        var payway = $('#payway').val();
        if (payway == '') {
            mui.alert('请选择邮寄方式！');
            return;
        }
        $('.set_default_Ads').each(function() {
            var src = $(this).find('img').attr('src');
            if (src == './images/express_btn_02_s.png') {
                var ads = $(this).parent().prev().find('.account_detail').eq(1).text();
                $("#mailAddress").text(ads);
                $("#recepter").val($(this).parent().prev().find('.account_detail').eq(0).find('span').eq(0).text());
                $("#receptphone").val($(this).parent().prev().find('.account_detail').eq(0).find('span').eq(1).text());
            }
        })
        hideIn();
    })
    // 点击提交
    $(".footer").click(function() {
        // 委方信息
        var conCustomername = $("#entrust span").text();
        var conCustomerid = $("#customerId").val();
        var conBankaccount = $("#conBankaccount").val();
        var conBankname = $("#conBankname").val();
        var conContacter = $("#contacter").val();
        var conContactphone = $("#contactphone").val();
        var conRegisteraddress = $("#registeraddress").val();
        var conTaxpayerid = $("#taxpayerid").val();
        // 购方信息
        var buyerBankaccount = $("#buyerBankaccount").val();
        var buyerBankname = $("#buyerBankname").val();
        var buyerContacter = $("#contacters").val();
        var buyerContactphone = $("#contactphones").val();
        var buyerEmail = $("#buyerEmail").val();
        var buyerId = $("#buyerIds").val();
        var buyerName = $("#buyername").text();
        var buyerRegisteraddress = $("#registeraddres_c").val();
        var buyerTaxpayerid = $("#taxpayerids").val();
        // 商品信息
        var goodsId = goodId.join(',');
        var invoicenote = $("#InvoiceRemark").val();
        var invoicetype = $("#invoiceType").val();
        var invoiceunion = $("#invoiceunion").val();
        var invoiceversion = $("#invoiceversion").val();
        // 寄付
        var payway = $('#payway').val();
        var isneedpost = $("#isneedpost").val();
        var ishassalelist = $("#ishassalelist").val();
        var address = $("#mailAddress").text();
        var recepter = $("#recepter").val();
        var receptphone = $("#receptphone").val();
        var remake = $("#GiveMeWords").val();
        // 发票类型判断
        if (invoicetype == 3) {
            if (buyerEmail == '') {
                mui.alert('请填写购方电子邮箱以便于发送电子发票！');
                return;
            }
        }
        if (conCustomerid == '') {
            mui.alert('请选择委方信息！');
            return;
        }
        if (buyerId == '') {
            mui.alert('请选择购方信息！');
            return;
        }
        if (goodsId == '') {
            mui.alert('请选择商品信息！');
            return;
        }
        if (invoiceversion == '') {
            mui.alert('请选择发票版本！');
            return;
        }
        if (invoiceunion == '') {
            mui.alert('请选择发票联次！');
            return;
        }
        var data = {
            conCustomername: conCustomername,
            conCustomerid: conCustomerid,
            conBankaccount: conBankaccount,
            conBankname: conBankname,
            conContacter: conContacter,
            conContactphone: conContactphone,
            conRegisteraddress: conRegisteraddress,
            conTaxpayerid: conTaxpayerid,
            buyerBankaccount: buyerBankaccount,
            buyerBankname: buyerBankname,
            buyerContacter: buyerContacter,
            buyerContactphone: buyerContactphone,
            buyerEmail: buyerEmail,
            buyerId: buyerId,
            buyerName: buyerName,
            buyerRegisteraddress: buyerRegisteraddress,
            buyerTaxpayerid: buyerTaxpayerid,
            goodsId: goodsId,
            invoicenote: invoicenote,
            invoicetype: invoicetype,
            invoiceunion: invoiceunion,
            invoiceversion: invoiceversion,
            payway: payway,
            isneedpost: isneedpost,
            address: address,
            recepter: recepter,
            receptphone: receptphone,
            recordGoodsList: recordGoodsList,
            remark: remake,
            ishassalelist: ishassalelist
        };
        $(this).css('pointer-events', 'none');
        $('.wrap').css('pointer-events', 'none');
        $.ajax({
            url: path + '/app/invoiceRecord/submit',
            dataType: 'json',
            type: 'post',
            headers: {
                userId: userId
            },
            xhrFields: {
                withCredentials: true
            },
            contentType: 'application/json',
            data: JSON.stringify(data),
            success: (data) => {
                console.log(data);
                if (data.success == 1) {
                    mui.alert(data.message, function() {
                        window.location.replace('./user.html');
                    });
                } else if (data.success == 0) {
                    mui.alert(data.message);
                    $(this).css('pointer-events', 'auto');
                    $('.wrap').css('pointer-events', 'auto');
                }
            },
            error: (err) => {
                mui.alert(err.message);
                $(this).css('pointer-events', 'auto');
                $('.wrap').css('pointer-events', 'auto');
            }
        })
    })
    // 搜索委方公司
    $(document).on('keypress', '#W_sear', function(e) {
        var customername = $(this).val();
        var keycode = e.keyCode;
        var searchName = $(this).val();
        if (keycode == '13') {
            e.preventDefault();
            $.ajax({
                url: path + '/app/customer/list',
                dataType: 'json',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                data: {
                    customername: customername
                },
                success: (data) => {
                    console.log(data);
                    var html = '';
                    $('.company_list').empty();
                    if (data.data.length > 0) {
                        for (var i = 0; i < data.data.length; i++) {
                            html += '<div class="info_name selectC">';
                            html += '<span>' + data.data[i].customername + '</span>';
                            html += '<input type="hidden" value="' + data.data[i].customerId + '"/>';
                            html += '</div>';
                        }
                    } else {
                        html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                        html += '<p class="result_note">暂无记录！</p>';
                    }
                    $('.company_list').append(html);
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            })
        }
    })
    // 行业查询
    $(document).on('keypress', '.industy', function(e) {
        var spmc = $(this).val();
        var keycode = e.keyCode;
        if (keycode == '13') {
            e.preventDefault();
            $.ajax({
                url: path + '/comm/industry/list',
                dataType: 'json',
                type: 'post',
                headers: {
                    userId: userId
                },
                xhrFields: {
                    withCredentials: true
                },
                data: {
                    spmc: spmc
                },
                success: (data) => {
                    console.log(data);
                    var html = '';
                    $('.industryList').empty();
                    if (data.data.length > 0) {
                        for (var i = 0; i < data.data.length; i++) {
                            if (data.data[i].childCount > 0) {
                                html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                                html += '<p class="industrylist_name">' + data.data[i].spmc + '<img src="./images/right.png" alt="" class="icon-right"/></p>';
                            } else {
                                html += '<input type="hidden" value="' + data.data[i].spbm + '"/>'
                                html += '<p class="industrylist_name">' + data.data[i].spmc + '</p>';
                            }
                        }
                    } else {
                        html += '<img src="./images/result_oops.png" alt="" class="result_oops"/>';
                        html += '<p class="result_note">暂无行业信息！</p>';
                    }
                    $('.industryList').append(html);
                },
                error: (err) => {
                    mui.alert(err.message);
                }
            })
        }
    })
    // 查看客户能开哪些发票
    $('.invoiceAllInfo').click(()=>{
        var html = '';
        $.each(datajson.data, function(index, datas) {
            if (datas.invoiceTypeName == '增值税普通发票') {
                html += '普票 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
            } else if (datas.invoiceTypeName == '电子发票') {
                html += '电子 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
            } else if (datas.invoiceTypeName == '通用机打发票') {
                html += '通用机打 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
            } else if (datas.invoiceTypeName == '增值税专用发票') {
                html += '专票 (' + datas.invoiceVersionName + '，' + datas.invoiceUnionName + ')\n';
            }
        })
        mui.alert(html, datajson.data[0].customername, '知道了');
    })
    // 关闭提示
    $('.icon-close').click(function(){
        $(this).parent().hide();
        event.stopPropagation();
    })
    //控制总价输入
    $(document).on('keyup','#totalprice',function(){
        num(this);
    })
</script>

</html>
